package foo.bar.wiki.web.action.general;

import foo.bar.wiki.web.action.BaseActionBean;
import foo.bar.wiki.web.extension.SpaceTypeConverter;
import foo.bar.wiki.web.nonextension.RomeSyndicationResolution;
import foo.bar.wiki.domain.Space;
import foo.bar.wiki.services.FeedType;
import foo.bar.wiki.services.FeedsService;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.validation.Validate;
import net.sourceforge.stripes.validation.EnumeratedTypeConverter;
import net.sourceforge.stripes.integration.spring.SpringBean;
import com.sun.syndication.feed.synd.SyndFeed;

/**
 * @author tmjee
 * @version $Date$ $Id$
 */
public class SpaceFeedsActionBean extends BaseActionBean {

    @Validate(converter = SpaceTypeConverter.class)
    private Space space;

    @Validate(converter = EnumeratedTypeConverter.class)
    private FeedType feedType = FeedType.rss_2_0;


    private FeedsService feedsService;

    @DefaultHandler
    public Resolution view() {
        SyndFeed feed = feedsService.produceSpaceFeeds(space, feedType);
        return new RomeSyndicationResolution(feed);
    }


    public Space getSpace() {
        return space;
    }

    public void setSpace(Space space) {
        this.space = space;
    }

    public FeedType getFeedType() {
        return feedType;
    }

    public void setFeedType(FeedType feedType) {
        this.feedType = feedType;
    }

    @SpringBean("feedsService")
    public void setFeedsService(FeedsService feedsService) {
        this.feedsService = feedsService;    
    }
}
